home *** CD-ROM | disk | FTP | other *** search
- (************************************************************************
- Program: CHGSYSDT.TPU
-
- Description: Full Month Calendar Unit for Turbo Pascal 5.0
-
- Author: Dennis Passmore
- 1421 PineTree Drive
- Edgewater, Fl. 32032
- (904) 427-8537 CIS 72746,2674
-
- Created: 1/14/1989
-
- Copyright (c) 1989 Dennis Passmore, all rights reserved.
-
- NO NONSENSE PROGRAM LICENSE
-
- Dennis Passmore reserves the COPYRIGHT to this program and all
- related materials. The user is granted a non-exclusive license to use
- the program and is encouraged to pay for the program if it is found
- to be useful. Payment of the $5 registration fee will entitle the
- user to full registration which includes permission to use this
- program in the user's OWN PERSONAL PROGRAMS. Programs which use
- CHGSYSDT.TPU and that are offered to the public either as commercial,
- shareware, or freeware must pay a site license fee of $25 to Dennis
- Passmore for use of CHGSYSDT.TPU.
-
- CONTACT DENNIS PASSMORE IF YOU PLAN TO USE ANY PART OF THIS UNIT.
-
- Dennis Passmore specifically disclaims all warranties, expressed or
- implied, including but not limited to, implied warranties of
- merchantability and fitness for any particular purpose. In no event
- shall Dennis Passmore be liable for any loss of profit or any other
- commercial damage, including but not limited to special, incidental,
- consequential or other damages.
-
-
- PROGRAM USE
-
- CHGSYSDT.TPU is a Turbo Pascal 5.0 unit designed to allow programmers
- to add full month calendar routines into their programs. The routines
- in CHGSYSDT.TPU will operate monochrome or color systems. The entire
- unit is self-contained and does not require error checking. Functions
- available through CHGSYSDT.TPU include:
-
- MoveToScreen ( moves contents of user buffer to screen )
-
- MoveFromScreen ( moves contents of screen to user buffer )
-
- Save_Screen ( allocates buffer space and saves screen data )
-
- Restore_Screen ( restores screen data and frees buffer space )
-
- Draw_Calendar ( draws full month calendar on screen )
-
- Select_New_Date ( draws calendar on screen and allows user to
- cursor select the month or date desired. )
-
-
- Sample Screen Output
- ╔═══════════════════════════╗
- ║ January 14, 1989 ║
- ╟───┬───┬───┬───┬───┬───┬───╢
- ║Sun│Mon│Tue│Wed│Thr│Fri│Sat║
- ╟───┼───┼───┼───┼───┼───┼───╢
- ║ 1│ 2│ 3│ 4│ 5│ 6│ 7║
- ╟───┼───┼───┼───┼───┼───┼───╢
- ║ 8│ 9│ 10│ 11│ 12│ 13│ 14║
- ╟───┼───┼───┼───┼───┼───┼───╢
- ║ 15│ 16│ 17│ 18│ 19│ 20│ 21║
- ╟───┼───┼───┼───┼───┼───┼───╢
- ║ 22│ 23│ 24│ 25│ 26│ 27│ 28║
- ╟───┼───┼───┼───┼───┼───┼───╢
- ║ 29│ 30│ 31│ │ │ │ ║
- ╟───┼───┼───┼───┼───┼───┼───╢
- ║ │ │ │ │ │ │ ║
- ╚═══╧═══╧═══╧═══╧═══╧═══╧═══╝
-
- ************************************************************************)
-
- unit ChgSysDt;
-
- interface
-
- uses
- Crt,
- Dos,
- StrOf, { from Turbo 4.0 manual page 355 or Turbo 5.0 manual page 213 }
-
- { The next 2 units are from the BORLAND TP4 SIG and were }
- Dates, { created by Scott Bussinger }
- Cursors; { Professional Practice Systems
- 110 South 131st Street
- Tacoma, WA 98444
- (206)531-8944
- Compuserve 72247,2671 }
-
-
- Procedure MoveToScreen(Var Source,Dest; Length: Integer);
-
- Procedure MoveFromScreen(Var Source,Dest; Length: Integer);
-
- procedure Save_Screen;
-
- procedure Restore_Screen;
-
- procedure Draw_Calendar(y,m,d: integer;x,z:integer);
- { parameters required are - Year , Month, Day and screen locations X, Z }
-
- procedure Select_New_Date;
-
- implementation
-
- const
- CGA = $B800;
- Mono = $B000;
-
- type
- vidbfr = array[1..4000] of byte;
- var
- mnth,day,
- year,wday: word;
- inkey : char;
- Jdate : date;
- saved : boolean;
- scrnloc : word;
- scrptr : pointer;
- scrbfr : ^vidbfr;
-
-
- procedure Initialize_Screen_Vars;
- begin
- if lastmode=7 then
- scrnloc := Mono
- else
- scrnloc := CGA;
- scrptr := ptr(scrnloc,0);
- saved := false;
- scrbfr := nil;
- end;
-
- { The next 2 procedures - MoveToScreen & MoveFromScreen are borrowed from }
- { someone else's code from a file on BORLAND TP3 SIG but I don't know who. }
-
- Procedure MoveToScreen(Var Source,Dest; Length: Integer);
- Begin
- If scrnloc=Mono Then
- Move(Source,Dest,Length)
- Else
- Begin
- Length:=Length Shr 1; { wait for retrace routine }
- Inline($1E/$55/$BA/$DA/$03/$C5/$B6/ Source /$C4/$BE/ Dest /$8B/$8E/
- Length /$FC/$AD/$89/$C5/$B4/$09/$EC/$D0/$D8/$72/$FB/$FA/$EC/
- $20/$E0/$74/$FB/$89/$E8/$AB/$FB/$E2/$EA/$5D/$1F);
- End;
- End;
-
- Procedure MoveFromScreen(Var Source,Dest; Length: Integer);
- Begin
- If scrnloc=Mono Then
- Move(Source,Dest,Length)
- Else
- Begin
- Length:=Length Shr 1; { wait for retrace routine }
- Inline($1E/$55/$BA/$DA/$03/$C5/$B6/ Source /$C4/$BE/ Dest /$8B/$8E/
- Length /$FC/$EC/$D0/$D8/$72/$FB/$FA/$EC/$D0/$D8/$73/$FB/$AD/
- $FB/$AB/$E2/$F0/$5D/$1F);
- End;
- End;
-
-
- procedure Save_Screen;
- begin
- if (not saved)and(memavail>4000) then
- begin
- saved := true;
- new(scrbfr);
- MoveFromScreen(scrptr^,scrbfr^,4000);
- end
- else
- write(^G);
- End;
-
- procedure Restore_Screen;
- begin
- if Saved then
- begin
- MoveToScreen(scrbfr^,scrptr^,4000);
- dispose(scrbfr);
- saved := false;
- end
- else
- write(^G);
- end;
-
- procedure Draw_Calendar(y,m,d: integer;x,z:integer);
- { parameters required are - Year , Month, Day and screen locations X, Z }
- const top_row = '╔═══════════════════════════╗';
- divider0 = '╟───┬───┬───┬───┬───┬───┬───╢';
- divider1 = '║Sun│Mon│Tue│Wed│Thr│Fri│Sat║';
- divider2 = '╟───┼───┼───┼───┼───┼───┼───╢';
- divider3 = '║ │ │ │ │ │ │ ║';
- bottom = '╚═══╧═══╧═══╧═══╧═══╧═══╧═══╝';
- var ix1,ix2,im,iy,wx,wy,
- sr,sc,nm,cday : integer;
- sMonth : String[36];
- sMl : byte absolute sMonth;
- tmp1,tmp2 : string[4];
- WinMin,WinMax,
- invatr,nrmatr : word;
- begin
- if (x<1) or (x>52) or ((x=52)and(z>8)) or (z<1) or (z>9) then
- write(^G)
- else
- begin
- { make sure we have a full size window before writing to the screen }
- WinMin := WindMin; WinMax := WindMax;
- wx := wherex; wy := wherey; window(1,1,80,25);
- str(d,tmp1); str(y,tmp2); ix2 := 0;
- sMonth := ' '+MonthString(m)+' '+tmp1+', '+tmp2+' ';
- if odd(sMl) then ix1:=14 else ix1:=13;
- gotoxy(x,z+ix2); write(top_row); inc(ix2);
- gotoxy(x,z+ix2); write('║'+stringof(' ',ix1-((sMl+1) div 2))+sMonth
- +stringof(' ',14-((sMl+1) div 2))+'║'); inc(ix2);
- gotoxy(x,z+ix2); write(divider0); inc(ix2);
- gotoxy(x,z+ix2); write(divider1); inc(ix2);
- for ix1 := 1 to 6 do
- begin
- gotoxy(x,z+ix2); write(divider2); inc(ix2);
- gotoxy(x,z+ix2); write(divider3); inc(ix2);
- end;
- gotoxy(x,z+ix2); write(bottom);
- iy := y; im := m;
- nm := im+1;
- if nm = 13 then nm := 1;
- DMYtoDate(1,im,iy,Jdate);
- ix1 := (Succ(Jdate) mod 7);
- sr := z+5; sc := x+1+(ix1*4);
- nrmatr := textattr;
- invatr := (textattr mod 16) shl 4+(textattr div 16);
- DatetoDMY(Jdate,cday,im,iy);
- repeat
- gotoxy(sc,sr);
- if d=cday then
- textattr := invatr;
- write(' ',cday:2);
- textattr := nrmatr;
- if (((cday+ix1)mod 7)=0) then
- begin
- inc(sr,2);
- sc := x+1;
- end
- else
- inc(sc,4);
- inc(jdate);
- DatetoDMY(Jdate,cday,im,iy);
- until (im=nm);
- inc(sr);
- if sr=z+14 then
- begin
- gotoxy(x,sr); write(divider2); inc(sr);
- gotoxy(x,sr); write(divider3); inc(sr);
- end;
- gotoxy(x,sr);
- write(bottom);
- { now we put it back to the way we found it }
- window(Lo(WinMin)+1,Hi(WinMin)+1,Lo(WinMax)+1,Hi(WinMax)+1);
- gotoxy(wx,wy);
- end;
- end;
-
- procedure Select_New_Date;
- const
- up1 = 1; dn1 = -1; zero = 0;
- var
- Jdate1, Jdate2 : date;
- year,mnth,day,wday : word;
- x,y,iyer,imth,iday : integer;
- begin
- GetDate(year,mnth,day,wday);
- iyer := year;
- imth := mnth;
- iday := day;
- DMYtoDate(iday,imth,iyer,Jdate1);
- Jdate2 := Jdate1;
- inkey := #0;
- x := 22;
- y := 5;
- Save_Screen;
- Makecursor(Nocursor);
- gotoxy(x+2,y+17); write(#27+#24+#25+#26+' Change «╝ To SetDate');
- gotoxy(x+10,y+18); write('ESC Exit');
- while not (inkey in [#13,#27]) do
- begin
- Draw_Calendar(iyer,imth,iday,x,y);
- repeat
- inkey := readkey;
- until inkey in [#0,#13,#27];
- if inkey = #0 then
- begin
- inkey := readkey;
- case inkey of
- #71: begin { Home - current date }
- Jdate2 := Jdate1;
- iyer := year;
- imth := mnth;
- iday := day;
- end;
- #72,#73,
- #75,#77,
- #80,#81: begin
- case inkey of
- { Up Ar - up a month } #72: Jdate2 := BumpDate(Jdate2,zero,up1,zero);
- { Pg Up - up a year } #73: Jdate2 := BumpDate(Jdate2,zero,zero,up1);
- { Left - down a day} #75: if Jdate2>0 then
- Jdate2 := BumpDate(Jdate2,dn1,zero,zero)
- else
- { Dn Ar - down a month } Jdate2 := BumpDate(Jdate2,zero,dn1,zero);
- { Right - up a day } #77: if Jdate2<65520 then
- Jdate2 := BumpDate(Jdate2,up1,zero,zero)
- else
- { Up Ar - up a month } Jdate2 := BumpDate(Jdate2,zero,up1,zero);
- { Dn Ar - down a month }#80: Jdate2 := BumpDate(Jdate2,zero,dn1,zero);
- { Pg Dn - down a year } #81: Jdate2 := BumpDate(Jdate2,zero,zero,dn1);
- end;
- DatetoDMY(Jdate2,iday,imth,iyer);
- end;
- else
- write(^G);
- end;
- end
- else
- if (inkey=#13)and(iyer<1980) then
- begin
- inkey := #0;
- write(^G);
- end;
- end;
- Restore_Screen;
- MakeCursor(RestoreCursor);
- year := iyer;
- mnth:= imth;
- day := iday;
- if inkey=#13 then
- SetDate(year,mnth,day);
- end;
-
- begin
- Initialize_Screen_Vars;
- end.
-